import { IPSAppDEField } from '../../app/dataentity/ipsapp-defield';
import { IPSCodeList } from '../../codelist/ipscode-list';
import { PSMDAjaxControlContainerImpl } from '../psmdajax-control-container-impl';
import { IPSSysCalendar } from './ipssys-calendar';
import { IPSSysCalendarItem } from './ipssys-calendar-item';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { IPSSysCss } from '../../res/ipssys-css';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';

export class PSSysCalendarImpl extends PSMDAjaxControlContainerImpl implements IPSSysCalendar {
  get calendarStyle(): 'DAY' | 'WEEK' | 'MONTH' | 'TIMELINE' | 'WEEK_TIMELINE' | 'MONTH_TIMELINE' | 'USER' | 'USER2' {
    return this.M.calendarStyle;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get emptyText(): string {
    return this.M.emptyText;
  }

  protected emptytextpslanguageres: IPSLanguageRes | null = null;

  getEmptyTextPSLanguageRes(): IPSLanguageRes | null {
    if (this.emptytextpslanguageres != null) return this.emptytextpslanguageres;
    const value = this.M.getEmptyTextPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.emptytextpslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getEmptyTextPSLanguageRes') as IPSLanguageRes;
    return this.emptytextpslanguageres;
  }

  get emptyTextPSLanguageRes(): IPSLanguageRes | null {
    return this.getEmptyTextPSLanguageRes();
  }

  getEmptyTextPSLanguageResMust(): IPSLanguageRes {
    const value = this.getEmptyTextPSLanguageRes();
    if (value == null) {
      throw new Error('未指定无值内容语言资源');
    }
    return value;
  }

  get groupHeight(): number {
    return this.M.groupHeight != null ? this.M.groupHeight : 0;
  }

  get groupLayout(): 'ROW' | 'COLUMN' {
    return this.M.groupLayout;
  }

  get groupMode(): 'NONE' | 'AUTO' | 'CODELIST' {
    return this.M.groupMode;
  }

  protected grouppsappdefield: IPSAppDEField | null = null;

  getGroupPSAppDEField(): IPSAppDEField | null {
    if (this.grouppsappdefield != null) return this.grouppsappdefield;
    const value = this.M.getGroupPSAppDEField;
    if (value == null) {
      return null;
    }
    this.grouppsappdefield = this.getPSModel4('app.dataentity.IPSAppDEField', value, 'getGroupPSAppDEField') as IPSAppDEField;
    return this.grouppsappdefield;
  }

  get groupPSAppDEField(): IPSAppDEField | null {
    return this.getGroupPSAppDEField();
  }

  getGroupPSAppDEFieldMust(): IPSAppDEField {
    const value = this.getGroupPSAppDEField();
    if (value == null) {
      throw new Error('未指定分组应用实体属性');
    }
    return value;
  }

  protected grouppscodelist: IPSCodeList | null = null;

  getGroupPSCodeList(): IPSCodeList | null {
    if (this.grouppscodelist != null) return this.grouppscodelist;
    const value = this.M.getGroupPSCodeList;
    if (value == null) {
      return null;
    }
    this.grouppscodelist = this.getPSModel4('codelist.IPSCodeList', value, 'getGroupPSCodeList') as IPSCodeList;
    return this.grouppscodelist;
  }

  get groupPSCodeList(): IPSCodeList | null {
    return this.getGroupPSCodeList();
  }

  getGroupPSCodeListMust(): IPSCodeList {
    const value = this.getGroupPSCodeList();
    if (value == null) {
      throw new Error('未指定分组代码表');
    }
    return value;
  }

  protected grouppssyscss: IPSSysCss | null = null;

  getGroupPSSysCss(): IPSSysCss | null {
    if (this.grouppssyscss != null) return this.grouppssyscss;
    const value = this.M.getGroupPSSysCss;
    if (value == null) {
      return null;
    }
    this.grouppssyscss = this.getPSModel4('res.IPSSysCss', value, 'getGroupPSSysCss') as IPSSysCss;
    return this.grouppssyscss;
  }

  get groupPSSysCss(): IPSSysCss | null {
    return this.getGroupPSSysCss();
  }

  getGroupPSSysCssMust(): IPSSysCss {
    const value = this.getGroupPSSysCss();
    if (value == null) {
      throw new Error('未指定分组默认界面样式');
    }
    return value;
  }

  protected grouppssyspfplugin: IPSSysPFPlugin | null = null;

  getGroupPSSysPFPlugin(): IPSSysPFPlugin | null {
    if (this.grouppssyspfplugin != null) return this.grouppssyspfplugin;
    const value = this.M.getGroupPSSysPFPlugin;
    if (value == null) {
      return null;
    }
    this.grouppssyspfplugin = this.getPSModel4('res.IPSSysPFPlugin', value, 'getGroupPSSysPFPlugin') as IPSSysPFPlugin;
    return this.grouppssyspfplugin;
  }

  get groupPSSysPFPlugin(): IPSSysPFPlugin | null {
    return this.getGroupPSSysPFPlugin();
  }

  getGroupPSSysPFPluginMust(): IPSSysPFPlugin {
    const value = this.getGroupPSSysPFPlugin();
    if (value == null) {
      throw new Error('未指定分组绘制插件');
    }
    return value;
  }

  get groupWidth(): number {
    return this.M.groupWidth != null ? this.M.groupWidth : 0;
  }

  get legendPos(): 'LEFT' | 'TOP' | 'RIGHT' | 'BOTTOM' | 'NONE' {
    return this.M.legendPos;
  }

  protected pssyscalendaritems: IPSSysCalendarItem[] | null = null;

  getPSSysCalendarItems(): IPSSysCalendarItem[] | null {
    if (this.pssyscalendaritems == null) {
      this.pssyscalendaritems = this.fillChildListModel(this.M.getPSSysCalendarItems, 'control.calendar.IPSSysCalendarItem') as IPSSysCalendarItem[];
    }
    return this.pssyscalendaritems;
  }

  get psSysCalendarItems(): IPSSysCalendarItem[] | null {
    return this.getPSSysCalendarItems();
  }

  findPSSysCalendarItem(objKey: any): IPSSysCalendarItem | null {
    return this.getPSModel5('control.calendar.IPSSysCalendarItem', this.getPSSysCalendarItems(), objKey) as IPSSysCalendarItem;
  }

  get hasWFDataItems(): boolean {
    return this.M.hasWFDataItems;
  }

  getHasWFDataItems(): boolean {
    return this.M.hasWFDataItems;
  }

  get enableEdit(): boolean {
    return this.M.enableEdit != null ? this.M.enableEdit : false;
  }

  get enableGroup(): boolean {
    return this.M.enableGroup;
  }

  get cls(): string {
    return 'PSSysCalendarImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.calendar.IPSDECalendar' || cls == 'control.calendar.IPSSysCalendar') return true;
    return super.instanceof(cls);
  }
}
